/**
 * Notes: 任务实体
 * Ver : CCMiniCloud Framework 2.0.1 ALL RIGHTS RESERVED BY cclinux0730 (wechat)
 * Date: 2024-03-10 19:20:00 
 */

const BaseProjectModel = require('./base_project_model.js');

class TaskModel extends BaseProjectModel {

}

// 集合名
TaskModel.CL = BaseProjectModel.C('oa_task');

TaskModel.DB_STRUCTURE = {
    _pid: 'string|true',
    TASK_ID: 'string|true',
    
    TASK_TITLE: 'string|true|comment=任务标题',
    TASK_PROJECT_ID: 'string|false|comment=关联项目ID',
    TASK_MILESTONE_ID: 'string|false|comment=关联里程碑ID',
    TASK_PARENT_TASK_ID: 'string|false|comment=父任务ID（如果是子任务）',
    
    TASK_TYPE: 'int|true|default=3|comment=类型：1=需求分析, 2=设计, 3=开发, 4=测试, 5=集成, 6=部署, 7=文档',
    TASK_STATUS: 'int|true|default=1|comment=状态：1=未开始, 2=进行中, 3=已完成, 4=已取消, 5=已暂停',
    TASK_PRIORITY: 'int|true|default=2|comment=优先级：1=低, 2=中, 3=高, 4=紧急',
    TASK_DESCRIPTION: 'string|false|comment=描述',
    
    TASK_PLAN_START_TIME: 'int|false|comment=计划开始时间',
    TASK_PLAN_END_TIME: 'int|false|comment=计划结束时间',
    TASK_ACTUAL_START_TIME: 'int|false|comment=实际开始时间',
    TASK_ACTUAL_END_TIME: 'int|false|comment=实际结束时间',
    
    TASK_ESTIMATED_HOURS: 'int|false|comment=预计工时',
    TASK_ACTUAL_HOURS: 'int|false|comment=实际工时',
    TASK_PROGRESS: 'int|true|default=0|comment=进度：0-100',
    
    TASK_ASSIGNEE_ID: 'string|false|comment=负责人ID',
    TASK_REPORTER_ID: 'string|false|comment=报告人ID',
    TASK_FOLLOWER_IDS: 'array|true|default=[]|comment=关注者ID数组',
    
    TASK_DEPENDENCY_TASK_IDS: 'array|true|default=[]|comment=依赖任务ID数组',
    TASK_TAGS: 'array|true|default=[]|comment=标签数组',
    TASK_ATTACHMENTS: 'array|true|default=[]|comment=附件URL数组',
    
    TASK_COMMENTS: 'array|true|default=[]|comment=评论数组',
    /*
    {
        userId: 'string', // 评论人ID
        content: 'string', // 评论内容
        createTime: 'int' // 创建时间
    }
    */
    
    TASK_ADD_USER_ID: 'string|false|comment=创建人ID',
    TASK_ADD_TIME: 'int|true',
    TASK_EDIT_TIME: 'int|true',
    TASK_ADD_IP: 'string|false',
    TASK_EDIT_IP: 'string|false',
};

// 字段前缀
TaskModel.FIELD_PREFIX = "TASK_";

/**
 * 类型：1=需求分析, 2=设计, 3=开发, 4=测试, 5=集成, 6=部署, 7=文档
 */
TaskModel.TYPE = {
    REQUIREMENT: 1,
    DESIGN: 2,
    DEVELOPMENT: 3,
    TESTING: 4,
    INTEGRATION: 5,
    DEPLOYMENT: 6,
    DOCUMENTATION: 7
};

TaskModel.TYPE_DESC = {
    REQUIREMENT: '需求分析',
    DESIGN: '设计',
    DEVELOPMENT: '开发',
    TESTING: '测试',
    INTEGRATION: '集成',
    DEPLOYMENT: '部署',
    DOCUMENTATION: '文档'
};

/**
 * 状态：1=未开始, 2=进行中, 3=已完成, 4=已取消, 5=已暂停
 */
TaskModel.STATUS = {
    NOT_STARTED: 1,
    IN_PROGRESS: 2,
    COMPLETED: 3,
    CANCELLED: 4,
    SUSPENDED: 5
};

TaskModel.STATUS_DESC = {
    NOT_STARTED: '未开始',
    IN_PROGRESS: '进行中',
    COMPLETED: '已完成',
    CANCELLED: '已取消',
    SUSPENDED: '已暂停'
};

/**
 * 优先级：1=低, 2=中, 3=高, 4=紧急
 */
TaskModel.PRIORITY = {
    LOW: 1,
    MEDIUM: 2,
    HIGH: 3,
    URGENT: 4
};

TaskModel.PRIORITY_DESC = {
    LOW: '低',
    MEDIUM: '中',
    HIGH: '高',
    URGENT: '紧急'
};

module.exports = TaskModel; 